<template>
  <j-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="meetingNum" label="会议号">
          <a-input placeholder="请输入会议号"  disabled v-model="model.meetingNum" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interviewDate" label="会议日期">
          <a-input placeholder="会议日期" disabled v-model="model.interviewDate" />
        </a-form-model-item>
		<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="beginTime" label="会议开始时间">
		  <a-input placeholder="会议开始时间" disabled v-model="model.beginTime" />
		</a-form-model-item>
		<!-- <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="endTime" label="会议结束时间">
		  <a-input placeholder="会议结束时间" disabled v-model="model.endTime" />
		</a-form-model-item> -->
		<a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status" label="是否通过">
		  	<a-radio-group :disabled="model.status == 1 || model.status == 2" :options="plainOptions" :default-value="model.orderStatus" @change="onChange" />
		</a-form-model-item>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>

<script>
  import { getAction } from '@/api/manage'
  import moment from "moment"
  export default {
    name: "InterviewDetailModal",
    data () {
      return {
		plainOptions:['通过', '未通过'],
        title:"操作",
        visible: false,
        model: {
			orderStatus: ''
		},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        validatorRules:{
        },
		status: '',
        url: {
          inviteInterview: "/wechat/wechatInterview/upStatus"
        },
      }
    },
    created () {
    },
    methods: {
	  onChange(e) {
		this.status = e.target.value == '通过' ? 1 : 2
	  },
      edit (record) {
        this.model = Object.assign({orderStatus: ''}, record.interList[0]);
		this.model.orderStatus = this.model.status == 1 ? '通过' : this.model.status == 2 ? '未通过' : ''
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // 触发表单验证
         this.$refs.form.validate(valid => {
          if (valid) {
			let param = {
				interId: this.model.id,
				status: this.status,
			}
            that.confirmLoading = true;
            if(!this.model.status) {
				getAction(this.url.inviteInterview,param,'get').then((res)=>{
				  if(res.success){
				    that.$message.success(res.message);
				    that.$emit('ok');
				  }else{
				    that.$message.warning(res.message);
				  }
				}).finally(() => {
				  that.confirmLoading = false;
				  that.close();
				})
			}else {
				that.close();
				that.$emit('ok');
			}
          }else{
             return false;
          }
        })
      },
      handleCancel () {
        this.close()
      },
    }
  }
</script>